<template>
  <div class="mx-auto w-full px-2">
    {{ logied ? '您已登录！' : '未登录，请登录' }}
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { sendMessage } from 'webext-bridge';
import { EXT_GET_USER_TOKEN } from '~/events';

const logied = ref(false);

async function checkAuth() {
  try {
    const resp = await sendMessage(EXT_GET_USER_TOKEN, {});
    if (resp) {
      logied.value = true;
    } else {
      logied.value = false;
    }
  } catch (error) {
    logied.value = false;
  }
}

checkAuth();
</script>
